package com.it.controller;

import com.google.code.kaptcha.Producer;
import com.it.config.KaptchaConfig;
import com.it.entity.SysUser;
import com.it.service.AuthService;
import com.it.vo.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录认证
 *
 * @author: Coke
 * @DateTime: 2023/11/19/14:21
 **/
@RestController
@Slf4j
public class AuthController {
    
    @Autowired
    private AuthService authService;
    

    /**
     * 生成验证码
     * @DateTime: 2023/11/19 14:28
     *
     * @param request:
     * @param response:
     * @return Response<?>
     * @author: Coke
     */
    @GetMapping("/captcha")
    public Response<?> captcha(HttpServletRequest request, HttpServletResponse response){
        return authService.captcha(request, response);
    }

    @PostMapping("/login")
    public Response<?> login(@RequestBody SysUser sysUser){
        return authService.login(sysUser);
    }
    
}
